#!/bin/bash
# 获取脚本所在的目录
DIR="$(cd "$(dirname "$0")" && pwd)"

# 获取同目录下的所有 jar 文件名
JAR_NAME=$(ls "$DIR"/*.jar 2>/dev/null | head -n 1)
if [ -z "$JAR_NAME" ]; then
    echo "No jar file found in current directory."
    exit 1
fi
FILE_NAME=$(basename "$JAR_NAME")
# 检查 JAR 文件的运行状态
STATUS=$(ps aux | grep -v grep | grep "$FILE_NAME" | wc -l)

if [ "$STATUS" -gt 0 ]; then
  echo "$FILE_NAME is running."
else
  echo "$FILE_NAME is not running."
fi